<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>数据类型转换</h1>

<script>

    //1.其它数据类型转换为String
    /*
    let num = 100;

    console.log(typeof(num.toString()));
    console.log(num.toString().valueOf());
    console.log(typeof(String(num)));
    console.log(String(num).valueOf());
    console.log(typeof(num+''));
    console.log((num+'').valueOf());*/

    //2.其它的数据类型转换为Number

    /*
    let str = "100";

    console.log(typeof(Number(str)));
    console.log(Number(str).valueOf());
    console.log(typeof(parseInt(str)));
    console.log(parseInt(str).valueOf());*/


    //3.自动类型转换

    let arr = [1,2,3,4,5];
    if(arr.length){
        console.log('true');
    }else{
        console.log('false')
    }
    console.log(100+false);
    console.log(100+true);
    console.log('100'+false);
    console.log('100'+100);


</script>


</body>
</html>